package com.lb.jwitter.action;


import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.lb.jwitter.util.ApplicationContextProvider; 
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.Map; 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; 
import org.springframework.test.context.ContextConfiguration;
import com.opensymphony.xwork2.ActionContext; 
import com.opensymphony.xwork2.Action; 
import com.lb.jwitter.service.ConditionReport;
import com.lb.jwitter.service.TblQuyenChiTietService;import com.lb.jwitter.service.TblTaiKhoan;import com.lb.jwitter.service.TblThongTinMonHoc;
import com.lb.jwitter.service.TblThongTinMonHocService;
import com.lb.jwitter.service.TblDKMHDotDK;
import com.lb.jwitter.service.TblDKMHDotDKService;

import com.lb.jwitter.service.TblCTDTMonHoc;
import com.lb.jwitter.service.TblCTDTMonHocService;

import com.lb.jwitter.service.TblCanBo;
import com.lb.jwitter.service.TblCanBoService;

 /** 
 * @author QUOCVIET  
 * 
 */ 


@ContextConfiguration(locations="classpath:beans.xml") 
public class TblThongTinMonHocEditFormAction{
    private int id; 
    public void setId(int id) {
       this.id = id;
 }

    public int getId() {
       return id;
 }

    private TblThongTinMonHoc tblThongTinMonHoc; 
    public TblThongTinMonHoc getTblThongTinMonHoc() { 
        return tblThongTinMonHoc; 
    } 
    private Collection<TblThongTinMonHoc> tblThongTinMonHocs; 
    public Collection<TblThongTinMonHoc>  getTblThongTinMonHocs() {
         return tblThongTinMonHocs; 
      } 

    private TblThongTinMonHocService tblThongTinMonHocService; 

    private Collection<TblDKMHDotDK> tblDKMHDotDKs; 
    public Collection<TblDKMHDotDK>  getTblDKMHDotDKs(){ 
              return tblDKMHDotDKs; 
     } 

    private TblDKMHDotDKService tblDKMHDotDKService; 

    private Collection<TblCTDTMonHoc> tblCTDTMonHocs; 
    public Collection<TblCTDTMonHoc>  getTblCTDTMonHocs(){ 
              return tblCTDTMonHocs; 
     } 

    private TblCTDTMonHocService tblCTDTMonHocService; 

    private Collection<TblCanBo> tblCanBos; 
    public Collection<TblCanBo>  getTblCanBos(){ 
              return tblCanBos; 
     } 

    private TblCanBoService tblCanBoService; 

  private TblTaiKhoan taiKhoanDangNhap; 
 public TblTaiKhoan getTaiKhoanDangNhap() { 
     return taiKhoanDangNhap; 
 } 
 public void setTaiKhoanDangNhap(TblTaiKhoan taiKhoanDangNhap) { 
     this.taiKhoanDangNhap = taiKhoanDangNhap; 
 } 
 private TblQuyenChiTietService tblQuyenChiTietService;
	 @Autowired // Injected by Spring 
     ApplicationContextProvider contextProvider; 
 public String execute() throws Exception 
{ 
 try{ 	
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_ThongTin_MonHoc", "sua")){ 
        return "noprivilege"; 
    } 
        tblThongTinMonHocService = (TblThongTinMonHocService) context.getBean("tbl_ThongTin_MonHocClient"); 
        tblDKMHDotDKService = (TblDKMHDotDKService) context.getBean("tbl_DKMH_DotDKClient"); 

        tblThongTinMonHoc = tblThongTinMonHocService.gettblThongTinMonHoc(new Long(id)); 
        List<ConditionReport> cons = new ArrayList<ConditionReport>(); 
        {
        	 ConditionReport con = new ConditionReport(); 
             con.setCol("id");
             con.setValue1("desc");
             con.setOperator("order");
             cons.add(con);	
        }
        tblDKMHDotDKs = tblDKMHDotDKService.findtblDKMHDotDKByCondition(cons, 20, 1);



        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi EditForm tbl_ThongTin_MonHoc Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 } 
 } 
 
